package jk.spider.core.throttle.impl;

import jk.spider.core.throttle.Throttle;
import jk.spider.core.throttle.ThrottleProvider;
import jk.spider.util.config.ConfigConstants;
import jk.spider.util.config.PropertySet;

public class RandomThrottleProvider implements ThrottleProvider {
	public static final String THINKTIME_MIN = "thinktime.min";
	public static final String THINKTIME_MAX = "thinktime.max";

	public static final int THINKTIME_MIN_DEFAULT = 10;
	public static final int THINKTIME_MAX_DEFAULT = 21;

	public Throttle createThrottle(PropertySet props) {
		int min = props.getInteger(ConfigConstants.THROTTLE_INTERVAL_MIN, THINKTIME_MIN_DEFAULT);
		int max = props.getInteger(ConfigConstants.THROTTLE_INTERVAL_MAX, THINKTIME_MAX_DEFAULT);
		return new RandomThrottleImpl(min, max);
	}

}
